package com.yupi.yoj.judge.codesandbox.service;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.yupi.yoj.judge.codesandbox.model.ExecuteCodeRequest;
import org.springframework.stereotype.Service;

@Service
public class ExecuteService {
    public void executePost(String url, ExecuteCodeRequest executeCodeRequest) {
        // 构建请求体
        String requestBody = JSONUtil.toJsonStr(executeCodeRequest);
        // 发送POST请求
        String result = HttpUtil.createPost(url)
                .body(requestBody)
                .contentType("application/json") // 设置内容类型为JSON
                .execute()
                .body();
        // 打印结果
        System.out.println(result);
    }
}
